package com.itheima.health.mobile.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.service.SetmealService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @autahor: csl
 * @date: 2019/7/21
 * @description:
 * @version:1.0
 */
@RestController
@RequestMapping("/mobile/setmeal")
public class SetmealController {
    @Reference
    private SetmealService service;
    @RequestMapping("/findAll")
    public Result findAll(){
         try {
                List<Setmeal> list= service.findAll();
                return new Result(true, MessageConst.QUERY_SETMEAL_SUCCESS,list);
                 }catch (Exception e){
                     e.printStackTrace();
                     return new Result(false,MessageConst.QUERY_SETMEAL_FAIL);
                 }
    }
    @RequestMapping("/getOrderSettingInfo")
    public Result getOrderSettingInfo(Integer id){
         try {
                Setmeal setmeal=  service.findSetmealById(id);
                return new Result(true,MessageConst.QUERY_SETMEAL_SUCCESS,setmeal);
                 }catch (Exception e){
                     e.printStackTrace();
                     return new Result(false,MessageConst.QUERY_SETMEAL_FAIL);
                 }
    }
}
